package com.cskaoyan.user.constants;


public enum UserRetCode {
    // 系统公用
    SUCCESS("000000", "成功"),

    USERORPASSWORD_ERRROR("003001", "密码不正确"),
    USER_NOT_EXIST_ERRROR("003001", "用户名不存在"),
    TOKEN_VALID_FAILED("003002", "token校验失败"),
    USERNAME_ALREADY_EXISTS("003003", "用户名已存在"),
    EMAIL_ALREADY_EXISTS("003003", "邮箱已存在"),
    USER_REGISTER_FAILED("003004", "注册失败，请联系管理员"),
    KAPTCHA_CODE_ERROR("003005", "验证码不正确"),
    USER_ISVERFIED_ERROR("003006", "用户名尚未激活"),
    USER_REGISTER_VERIFY_FAILED("003007", "用户注册失败插入验证数据失败"),
    USER_INFOR_INVALID("003004", "用户信息不合法"),
    USER_INFOR_UPDATE_FAIL("003008", "用户信息修改失败"),

    REQUEST_FORMAT_ILLEGAL("003060", "请求数据格式非法"),
    REQUEST_IP_ILLEGAL("003061", "请求IP非法"),
    REQUEST_CHECK_FAILURE("003062", "请求数据校验失败"),
    DATA_NOT_EXIST("003070", "数据不存在"),
    DATA_REPEATED("003071", "数据重复"),
    REQUEST_DATA_NOT_EXIST("003072", "传入对象不能为空"),
    REQUEST_DATA_ERROR("003074", "必要的参数不正确"),
    REQUISITE_PARAMETER_NOT_EXIST("003073", "必要的参数不能为空"),
    PERMISSION_DENIED("003091", "权限不足"),
    DB_EXCEPTION("003097", "数据库异常"),
    SYSTEM_TIMEOUT("003098", "系统超时"),
    SYSTEM_ERROR("003099", "系统错误"),

    USERVERIFY_INFOR_INVALID("003200", "用户注册验证验证信息不合法"),

    ADDRESS_ID_NOT_EXSITS("003201", "AdressId不存在"),
    GENERATE_VERIFY_CODE_FAIL("003202", "生成验证码失败"),
    REGISTER_ACTIVATION_MAIL_SEND_FAIL("003202", "生成验证码失败"),

    REGISTER_PASS_VERIFY_ERR("003004","密码必须6-16位,包含字母和数字的组合,不能使用特殊字符"),
    REGISTER_USERNAME_VERIFY_ERR("003004","用户名必须(字母开头，允许5-18字节，允许字母数字下划线"),
    REGISTER_EMAIL_VERIFY_ERR("003004","邮箱格式不合法"),
    USER_ISVERIFY("003001","用户已激活,请勿重复操作"),
    USER_UUID_ERROR("003001","请检查连接是否正确");
    private String code;
    private String message;

    UserRetCode(String code, String message) {
        this.code = code;
        this.message = message;
    }

    /**
     * Getter method for property <tt>code</tt>.
     *
     * @return property value of code
     */
    public String getCode() {
        return code;
    }

    /**
     * Setter method for property <tt>code</tt>.
     *
     * @param code value to be assigned to property code
     */
    public void setCode(String code) {
        this.code = code;
    }

    /**
     * Getter method for property <tt>message</tt>.
     *
     * @return property value of message
     */
    public String getMessage() {
        return message;
    }

    /**
     * Setter method for property <tt>message</tt>.
     *
     * @param message value to be assigned to property message
     */
    public void setMessage(String message) {
        this.message = message;
    }

    public static String getMessage(String code) {
        for (UserRetCode s : UserRetCode.values()) {
            if (null == code)
                break;
            if (s.code.equals(code)) {
                return s.message;
            }
        }
        return null;
    }
}
